/*********************************************************************************
Organization 					: 				Georgia Institute of Technology
  
Institute 						:				Cognitive Computing Group(CCL)
 
Authors							: 				Santiago Ontanon, Kinshuk Mishra
 												Neha Sugandh 
 												
Class							:				TimeOutCondition
 
Function						: 				Provides a class for holding a timeout
												condition
****************************************************************************/

package planninglanguage.conditions;

import org.jdom.Element;

import util.XMLWriter;

public class TimeOutCondition extends Condition {
	public static enum TimeOutType {start, end};
	
	int m_cycles;
	TimeOutType type;
	public TimeOutCondition(int a_cycles,TimeOutType a_type)
	{
		m_cycles = a_cycles;
		type = a_type;
	}
	public TimeOutType getType()
	{
		return type;
	}
	public String toString(int tabs)
	{
		String n = super.toString(tabs);
		n = n + "Number of Cycles is:" + m_cycles;
		return n;
	}
	
	public void writeXML(XMLWriter w) {
		w.tag("condition type=\""+this.getClass().getSimpleName()+"\"");
		{
			w.tag("cycles", m_cycles);
			w.tag("type", type.toString());
		}
		w.tag("/condition");
	}
	
	protected static Condition loadConditionFromXML(Element e) {
		return new TimeOutCondition(Integer.parseInt(e.getChildText("cycles")),
				TimeOutType.valueOf(e.getChildText("type")));
	}
}
